home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / examples / C / x19c.c < prev   
Encoding:
C/C++ Source or Header  |  1994-07-30  |  2.0 KB  |  98 lines

  1. /* $Id: x19c.c,v 1.1 1994/07/29 20:14:45 mjl Exp $
  2.  * $Log: x19c.c,v $
  3.  * Revision 1.1  1994/07/29  20:14:45  mjl
  4.  * Demo for generating world map backgrounds.
  5.  * Contributed by Wesley Ebisuzaki.
  6.  *
  7. */
  8.  
  9. /*    x19c.c
  10.  
  11.     Illustrates backdrop plotting of world, US maps.
  12.     Contributed by Wesley Ebisuzaki.
  13. */
  14.  
  15. #include <plplot.h>
  16.  
  17. /* define pi if not defined by math.h */
  18.  
  19. #ifndef PI
  20. #define PI 3.1416
  21. #endif
  22.  
  23. /*----------------------------------------------------------------------*\
  24.  * mapform
  25.  *
  26.  * Defines our coordinate transformation.
  27.  * x[], y[] are the coordinates to be plotted.
  28. \*----------------------------------------------------------------------*/
  29.  
  30. void 
  31. mapform(PLINT n, PLFLT *x, PLFLT *y) 
  32. {
  33.     int i;
  34.     double xp, yp, radius;
  35.     for (i = 0; i < n; i++) {
  36.     radius = 90.0 - y[i];
  37.     xp = radius * cos(x[i] * PI / 180.0);
  38.     yp = radius * sin(x[i] * PI / 180.0);
  39.     x[i] = xp;
  40.     y[i] = yp;
  41.     }    
  42. }
  43.  
  44. /*----------------------------------------------------------------------*\
  45.  * main
  46.  *
  47.  * Shows two views of the world map.
  48. \*----------------------------------------------------------------------*/
  49.  
  50. void 
  51. main(int argc, char **argv) 
  52. {
  53.     PLFLT minx, maxx, miny, maxy;
  54.     int c;
  55.  
  56.     /* Parse and process command line arguments */
  57.  
  58.     (void) plParseInternalOpts(&argc, argv, PL_PARSE_FULL);
  59.  
  60.     /* Longitude (x) and latitude (y) */
  61.  
  62.     miny = -70;
  63.     maxy = 80;
  64.  
  65.     plinit();
  66.  
  67.     /* Cartesian plots */
  68.     /* Most of world */
  69.  
  70.     minx = 190;
  71.     maxx = 190+360;
  72.  
  73.     plcol(1);
  74.     plenv(minx, maxx, miny, maxy, 1, -1);
  75.     plmap(NULL, "usaglobe", minx, maxx, miny, maxy);
  76.  
  77.     /* The Americas */
  78.  
  79.     minx = 190;
  80.     maxx = 340;
  81.  
  82.     plcol(1);
  83.     plenv(minx, maxx, miny, maxy, 1, -1);
  84.     plmap(NULL, "usaglobe", minx, maxx, miny, maxy);
  85.  
  86.     /* Polar, Northern hemisphere */
  87.  
  88.     minx = 0;
  89.     maxx = 360;
  90.  
  91.     plenv(-75., 75., -75., 75., 1, -1);
  92.     plmap(mapform,"globe", minx, maxx, miny, maxy);
  93.  
  94.     pllsty(2);
  95.     plmeridians(mapform,10.0, 10.0, 0.0, 360.0, -10.0, 80.0);
  96.     plend();
  97. }
  98.